import axios from 'axios'
import store from '../store'

const api = axios.create({
  baseURL: '/',
  timeout: 600
})


api.interceptors.request.use(function (config) {
  store.dispatch('showLoading')
  return config
}, function (err) {
  return Promise.reject(err)
})

api.interceptors.response.use(function (response) {
  store.dispatch('hideLoading')
  return response
}, function (err) {
  return Promise.reject(err)
})

export default api
